# 最小 CMake 版本要求
cmake_minimum_required(VERSION 3.10)

# 项目名称
project(MyProject)

# 定义可选组件的选项
option(BUILD_ComponentA "Build the ComponentA library" OFF)
option(BUILD_ComponentB "Build the ComponentB library" OFF)

# 主程序或其他组件
add_executable(MyExecutable main.c)

# 包含 components 目录，并获取构建的库列表
set(COMPONENT_LIBS "")
add_subdirectory(components)

# 链接所有启用的组件到主程序
foreach(COMPONENT IN LISTS COMPONENT_LIBS)
    target_link_libraries(MyExecutable PRIVATE ${COMPONENT})
endforeach()